﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>会员等级</title>
    <script src="../../Scripts/jquery-1.9.1.js" type="text/javascript"></script>
     <script src="../../Content/JS/layer-v1.7.1/layer/layer.js" type="text/javascript"></script>
    <link href="../../Content/Themes/blue2/css.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    .showtable{ width:800px;  margin:0px auto;}
    .cs_table{width:800px; border-color:#1C1C1C; overflow:scroll;text-align:center;border-collapse:collapse; border-spacing:0; margin-bottom:10px;  margin-top:5px;}
    .cs_table th,td{ word-break:keep-all; white-space:nowrap;  border:1px black solid ; padding:3px; }
    .show_btn{ margin-top:11px; text-align:right; }
    .clickColor{ background-color:#bed3ef;color:#5291E2;font-weight:bold; }
    </style>
</head>
<body class="main">
     <div class="AllWebTopDiv">
        <div class="path">
            <div class="nav">
                <a href="#">会员等级</a>
            </div>
        </div>
       <div class="content">
        <div class="showtable">
          <div class="show_btn">
            <input  type="button" value="添加" class="button2" onclick="addSolution()"/>
            <input  type="button" value="修改" class="button2"  onclick="editSolution()"/>
            <input  type="button" value="删除" class="button2" onclick="delSolution()"/>
            <input  type="button" value="关闭" id="btn_cancel" onclick="closeWindows();"  class="button2"/>
          </div>
          <table class="cs_table">
             <tr class="DGHeaderStyle">
               <td>方案编号</td>
               <td>方案名称</td>
               <td>模版名</td>
               <td>消费方案</td>
               <td>充值方案</td>
               <td>折扣比率</td>
               <td>下一等级</td>
               <td>升级条件</td> 
               <td>延期天数</td> 
             </tr>
          </table>
         
        </div>
       </div>
    </div>
</body>
</html>
<script type="text/javascript">
   
   //加载方案
    $.ajax({
             type:"POST",
             url:"<%:Url.Action("LoadSolution","ConsumeSolution") %>",
             data:"",
             cache:false,
             success:function(html){
             $(".cs_table").append(html);
             }
           })   

     //添加方案
     function addSolution(){
        $.layer({
                        type: 2,
                        title: false,
                        closeBtn:false,
                       shadeClose: true, //开启点击遮罩关闭层
                        move: ['.juanmove', true],
                       area: ['570px', '500px'],
                       offset: ['100px', ''],
                       iframe: { src: "/ConsumeSolution/ConsumeSolutionSetting" },
                         success:function(){
                           layer.shift('top',500);
                                  }
                     });
     }

     //编辑方案
     function editSolution(){
       $.layer({
                        type: 2,
                        title: false,
                        closeBtn:false,
                       shadeClose: true, //开启点击遮罩关闭层
                        move: ['.juanmove', true],
                       area: ['570px', '500px'],
                       offset: ['100px', ''],
                       iframe: { src: "/ConsumeSolution/ConsumeSolutionSetting?Id="+Id },
                         success:function(){
                           layer.shift('top',500);
                                  }
                     });
     }

   
     //删除方案
     function delSolution(){
       reg = /^[-+]?\d*$/;
       if(!reg.test(Id)){
          alert("请选中要删除的行"+Id);
          return false;
       }

        $.layer({
                  shade:[0.5,'#000',true],
                  area:['310px', '130px'],
                  dialog:{
                      msg:'您确定要删除该方案吗',
                      btns:2,
                      type:4,
                      btn: ['确定','取消'],
                      yes:function(){
                          $.ajax({
                             type:"POST",
                              url:"<%:Url.Action("delSolution","ConsumeSolution") %>",
                             data:"Id="+Id+"",
                             cache:false,
                             success:function(txt){
                              if(txt=="级联") {
                                layer.msg("数据有级联,请先删除其他方案的下一等级为此方案的",4);
                              }
                              else {
                                if(txt=="会员卡号"){
                                layer.msg("会员列表中有用此方案的会员,删除失败",3);
                                }
                                else{
                                layer.msg(txt,2,function(){location.reload('<%:Url.Action("ConsumeSolution","ConsumeSolution") %>');});
                                }
                              }
                                 }
                            })

                      },no:function(){
                         layer.closeAll();
                      }
                  }
              
              });
     
     }
      //选择行
     var Id="";
      function selectSolution(o){
          $(".cs_table tr").each(
                 function(){
                   var id=$(this).children("td").eq(0).text();
                    var parseGoodId=parseFloat(id);
                    if(parseGoodId==o){
                       Id=id;
                       $(this).children().addClass("clickColor");
                    }
                    else{
                     $(this).children().removeClass("clickColor");
                    }
                    
                 }
          
          );
      
      }

      //关闭窗口
    function closeWindows() {
        window.location.href = "/Loading/Index/?src=/Desktop/Index/";
    }
</script>
